package com.hmsm.sys.daoImpl;

import java.util.List;

import com.hmsm.server.base.BaseDao;
import com.hmsm.server.common.KeyBean;
import com.hmsm.sys.dao.FuncInfoDao;
import com.hmsm.sys.po.FuncInfo;

public class FuncInfoDaoImpl extends BaseDao<FuncInfo, Integer> implements FuncInfoDao {
	
	/**
	 * 根据组角色ID获取功能项信息
	 * @param roleId
	 * @return
	 * @author lzyyj
	 */
	@SuppressWarnings("unchecked")
	public List<KeyBean> getFuncInfoByRoleId(Integer roleId){
		String hql = "select new com.hmsm.server.common.KeyBean(f.pkId, CASE WHEN fg.parentId = 0 THEN f.funcCode ELSE CONCAT(fg.funcCode,':',f.funcCode) END) from RoleFunc rf, FuncInfo f, FuncInfo fg where  f.pkId = rf.funcId AND fg.pkId = f.parentId AND rf.state = 1 and rf.roleId = "+roleId;
		return this.getHibernateTemplate().find(hql);
	}

	/**
	 *  @描述:获取指定功能项
	 *  @方法名称:queryAll
	 *  @作者:yaosq
	 *  @创建日期:2014-4-1 下午02:09:30 
	 *  @param hql
	 *  @return
	 */
	public List<FuncInfo> queryAll(String hql) {
		List<FuncInfo> funcInfos = queryByHql(hql);
		return funcInfos;
	}

}
